package com.ruoyi.basebill.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.basebill.domain.OmsSalereturnbillentry;
import com.ruoyi.basedata.domain.OmsSettlementrateentrytwo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basebill.domain.OmsSalereturnbill;
import com.ruoyi.basebill.service.IOmsSalereturnbillService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * OMS销售退货单Controller
 * 
 * @author ptt
 * @date 2023-02-10
 */
@RestController
@RequestMapping("/settlementCenter/basebill/salereturnbill")
public class OmsSalereturnbillController extends BaseController
{
    @Autowired
    private IOmsSalereturnbillService omsSalereturnbillService;

    /**
     * 查询OMS销售退货单列表
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:salereturnbill:list')")
    @GetMapping("/list")
    public TableDataInfo list(OmsSalereturnbill omsSalereturnbill)
    {
        startPage();
        List<OmsSalereturnbill> list = omsSalereturnbillService.selectOmsSalereturnbillList(omsSalereturnbill);
        return getDataTable(list);
    }

    /**
     * 导出OMS销售退货单列表
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:salereturnbill:export')")
    @Log(title = "OMS销售退货单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OmsSalereturnbill omsSalereturnbill)
    {
        List<OmsSalereturnbill> list = omsSalereturnbillService.selectOmsSalereturnbillDetailList(omsSalereturnbill);
        ExcelUtil<OmsSalereturnbill> util = new ExcelUtil<OmsSalereturnbill>(OmsSalereturnbill.class);
        util.exportExcel(response, list, "OMS销售退货单数据");
    }



    @PostMapping("/importTemplateEntry")
    public void importTemplateEntry2(HttpServletResponse response){
        ExcelUtil<OmsSalereturnbillentry> util = new ExcelUtil<>(OmsSalereturnbillentry.class);
        util.importTemplateExcel(response,"价格策略组织分录信息");
    }



    /**
     * 获取OMS销售退货单详细信息
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:salereturnbill:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(omsSalereturnbillService.selectOmsSalereturnbillById(id));
    }

    /**
     * 新增OMS销售退货单
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:salereturnbill:add')")
    @Log(title = "OMS销售退货单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OmsSalereturnbill omsSalereturnbill)
    {
        return toAjax(omsSalereturnbillService.insertOmsSalereturnbill(omsSalereturnbill));
    }

    /**
     * 修改OMS销售退货单
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:salereturnbill:edit')")
    @Log(title = "OMS销售退货单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OmsSalereturnbill omsSalereturnbill)
    {
        return toAjax(omsSalereturnbillService.updateOmsSalereturnbill(omsSalereturnbill));
    }

    /**
     * 删除OMS销售退货单
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:salereturnbill:remove')")
    @Log(title = "OMS销售退货单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(omsSalereturnbillService.deleteOmsSalereturnbillByIds(ids));
    }
}
